package se.mushroomwars.mapeditor.model;

import java.awt.Point;
import java.util.HashSet;

public class PathRec {
	private PathRec previous;	
	private double distance;
	private Point position;
	private HashSet<Point> list;
	
	public PathRec (Point pos, PathRec pre, double dis) {
		position = pos;
		previous = pre;
		list = new HashSet<Point>();		
		if (previous != null) {
			distance = previous.getDistance() + dis;
			list = previous.getList();
		} else
			distance = dis;
		list.add(pos);
	}
	
	public double getDistance() {
		return distance;
	}
	
	public Point getPosition() {
		return position;
	}
	
	public boolean contains (Point pos) {
		return list.contains(pos);
	}
	
	public PathRec getPrev() {
		return previous;
	}
	
	public HashSet<Point> getList() {
		HashSet<Point> tmp = new HashSet<Point>();
		tmp.addAll(list);
		return tmp;
	}
}
